<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">投递管理</ui:define>
    <ui:define name="content">

        <h:form>
            <p:dialog id="createModal" header="新增" position="center" widgetVar="createPrepaidModal"
                      modal="true" width="600px"
                      >
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="ownername" value="甲方名称"/>
                    <p:inputText id="ownername" value="#{loanLargeDeliveryManagementBean.$.ownner}" style="width:100%"/>

                    <p:outputLabel for="type" value="API编号"/>
                    <p:inputText id="type" value="#{loanLargeDeliveryManagementBean.$.type}" style="width:100%"/>

                    <p:outputLabel for="amountinterval" value="金额区间"/>
                    <p:selectOneMenu id="amountinterval" value="#{loanLargeDeliveryManagementBean.$.amountinterval}">
                        <f:selectItems
                                value="#{loanLargeDeliveryManagementBean.dictionaries[DictionaryCode.PRODUCT_MONEY]}"
                                var="dic"
                                itemLabel="#{dic.name}" itemValue="#{dic.name}"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="delivermethod" value="推广方式"/>
                    <p:selectOneMenu id="delivermethod" value="#{loanLargeDeliveryManagementBean.$.delivermethod}">
                        <f:selectItem itemLabel="外推" itemValue="外推"/>
                        <f:selectItem itemLabel="站内" itemValue="站内"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="sort" value="投递优先级"/>
                    <p:inputText id="sort" value="#{loanLargeDeliveryManagementBean.$.sort}" style="width:100%"/>

                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="保存" actionListener="#{loanLargeDeliveryManagementBean.onCreate}"
                                     process="createModal" update="@form" />
                </div>
            </p:dialog>

            <p:dialog id="editModal" header="编辑" position="center" widgetVar="editPrepaidModal"
                      modal="true" width="600px"
                      >
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">
                    <p:outputLabel for="ownernameedit" value="甲方名称"/>
                    <p:inputText id="ownernameedit" value="#{loanLargeDeliveryManagementBean.$.ownner}" style="width:100%"/>

                    <p:outputLabel for="typeedit" value="API编号"/>
                    <p:inputText id="typeedit" value="#{loanLargeDeliveryManagementBean.$.type}" disabled="true" style="width:100%"/>

                    <p:outputLabel for="amountintervaledit" value="金额区间"/>
                    <p:selectOneMenu id="amountintervaledit" value="#{loanLargeDeliveryManagementBean.$.amountinterval}">
                        <f:selectItems
                                value="#{loanLargeDeliveryManagementBean.dictionaries[DictionaryCode.PRODUCT_MONEY]}"
                                var="dic"
                                itemLabel="#{dic.name}" itemValue="#{dic.name}"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="delivermethodedit" value="推广方式"/>
                    <p:selectOneMenu id="delivermethodedit" value="#{loanLargeDeliveryManagementBean.$.delivermethod}">
                        <f:selectItem itemLabel="外推" itemValue="外推"/>
                        <f:selectItem itemLabel="站内" itemValue="站内"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="sortedit" value="投递优先级"/>
                    <p:inputText id="sortedit" value="#{loanLargeDeliveryManagementBean.$.sort}" style="width:100%"/>

                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确认修改" actionListener="#{loanLargeDeliveryManagementBean.onEdit}" process="editModal" update="@form"/>
                </div>
            </p:dialog>

            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="LoanWholeSaleCommentDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         rendered="#{loanLargeDeliveryManagementBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="禁用" icon="fa fa-times"
                                         rendered="#{loanLargeDeliveryManagementBean.isBatch()}"
                                         actionListener="#{loanLargeDeliveryManagementBean.onBatchDisable()}"
                                         update="@form"/>
                        <p:commandButton value="启用" icon="fa fa-check"
                                         rendered="#{loanLargeDeliveryManagementBean.isBatch()}"
                                         actionListener="#{loanLargeDeliveryManagementBean.onBatchEnable()}"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{loanLargeDeliveryManagementBean.isNormal()}"
                                         actionListener="#{loanLargeDeliveryManagementBean.onReset}"
                                         process="@this" update="@form"/>
                        <p:commandButton value="新建" icon="fa fa-plus"
                                         actionListener="#{loanLargeDeliveryManagementBean.onCreateTarget}"
                                         oncomplete="PF('createPrepaidModal').show()"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="ui-g-12 card">
                            <h1>查询条件</h1>
                            <div class="ui-g-1">
                                <p:outputLabel for="partnerNameInput" value="甲方名称"/>
                            </div>
                            <div class="ui-g-3">
                                <p:inputText id="partnerNameInput" value="#{loanLargeDeliveryManagementBean.$.ownner}"/>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="推广方式"/>
                            </div>
                            <div class="ui-g-3">
                                <p:selectOneMenu id="query_delivermethod" value="#{loanLargeDeliveryManagementBean.$.delivermethod}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="外推" itemValue="外推"/>
                                    <f:selectItem itemLabel="站内" itemValue="站内"/>
                                </p:selectOneMenu>
                            </div>
                            <div class="ui-g-1">
                                <p:outputLabel value="金额区间"/>
                            </div>
                            <div class="ui-g-3">
                                <p:selectOneMenu id="query_money" value="#{loanLargeDeliveryManagementBean.$.amountinterval}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanLargeDeliveryManagementBean.dictionaries[DictionaryCode.PRODUCT_MONEY]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.name}"/>
                                </p:selectOneMenu>
                            </div>
                        </div>
                        <div class="card">
                            <p:dataTable id="LoanWholeSaleCommentDataTable"
                                         style="width: 100%;text-align:center"
                                         var="prepaid"
                                         value="#{loanLargeDeliveryManagementBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{loanLargeDeliveryManagementBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="操作" style="width:70px;" rendered="#{loanLargeDeliveryManagementBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-credit-card"
                                                   actionListener="#{loanLargeDeliveryManagementBean.onEditTarget(prepaid)}"
                                                   oncomplete="PF('editPrepaidModal').show()"
                                                   process="@this" update="@form">
                                        <p:menuitem value="删除" icon="fa fa-times"
                                                    actionListener="#{loanLargeDeliveryManagementBean.onDelete(prepaid)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="信息提示" message="确定删除么？" icon="ui-icon-alert" width="10%"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>

                                <p:column headerText="甲方名称">
                                    <h:outputText value="#{prepaid.ownner}"/>
                                </p:column>

                                <p:column headerText="投递优先级" style="text-align:left;">
                                    <h:outputText value="#{prepaid.sort}"/>
                                </p:column>

                                <p:column headerText="API模板id" style="text-align:right;">
                                    <h:outputText value="#{prepaid.type}"/>
                                </p:column>

                                <p:column headerText="推广方式">
                                    <h:outputText value="#{prepaid.delivermethod}"/>
                                </p:column>

                                <p:column headerText="金额区间">
                                    <h:outputText value="#{prepaid.amountinterval}"/>
                                </p:column>

                                <p:column headerText="操作人">
                                    <h:outputText value="#{prepaid.operator}"/>
                                </p:column>

                                <p:column headerText="操作时间">
                                    <h:outputText value="#{prepaid.operatime}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
